{% extends "base.html" %}

{% block cur_user %}
  <div style="display: inline">
    <a class="nav-link px-3" style="display: inline-block;" href="/">{{ user.username }}</a>
    <a class="nav-link px-3" style="display: inline-block;" href="{{ url_for('logout') }}">Logout</a>
  </div>
{% endblock %}

{% block uid %}
  UID: {{ info.acc_info.uid }}
{% endblock %}
{% block accounts %}
  <ul class="nav flex-column mb-2">
    {% for acc in accounts %}
      <li class="nav-item">
        <form class="form-inline" style="display: none" role="form" id="accform{{ acc.token }}" action="/analyze" method="post">
          <div class="form-group">
              <input type="text" class="form-control" id="token" name="token" value={{ acc.token }}>
          </div>
        </form>
        <button type="submit" form="accform{{ acc.token }}" class="nav-link btn btn-sm btn-outline-secondary" style="border:none">
          <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text" aria-hidden="true"><image xlink:href="https://gitee.com/RWoxiN/image-bed/raw/master/Image/202203031635528.jpeg" width="20" height="20"/></svg>
          {% if acc.uid is equalto info.acc_info.uid %}
            <font color='red'>{{ acc.nickName }}</font>
          {% else %}
            <font color='black'>{{ acc.nickName }}</font>
          {% endif %}
        </button>
      </li>
    {% endfor %}
  </ul>
{% endblock %}
{% block main %}
  <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">{{ info.acc_info.nickName }}</h1>
    <div class="btn-toolbar mb-2 mb-md-0">
      <div class="btn-group me-2">
        <form class="form-inline" style="display: none" role="form" id="refform" action="/analyze/refresh" method="post">
          <div class="form-group">
              <input type="text" class="form-control" id="token" name="token" value={{ info.acc_info.token }}>
          </div>
        </form>
        <button type="submit" form="refform" class="btn btn-sm btn-outline-secondary">Refresh</button>
        <form class="form-inline" style="display: none" role="form" id="forcerefform" action="/analyze/refresh/force" method="post">
          <div class="form-group">
              <input type="text" class="form-control" id="token" name="token" value={{ info.acc_info.token }}>
          </div>
        </form>
        <button type="submit" form="forcerefform" class="btn btn-sm btn-outline-secondary">Force Refresh</button>
      </div>
    </div>
  </div>

  <h2>抽卡数据</h2>
  <a>{{ info.osr_info.time.start_time }} - {{ info.osr_info.time.end_time }}</a>
  <div class="table-responsive">
    <table class="table table-striped table-sm" style="border-collapse: collapse; table-layout: fixed;">
      <thead>
        <tr>
          <th scope="col">总计</th>
          <th scope="col">{{ info.osr_info.osr_number.total.all }} 抽</th>
          <th scope="col">占比</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>六星</td>
          <td>{{ info.osr_info.osr_number.total['6'] }} 抽</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_number.total['6'] / info.osr_info.osr_number.total.all * 100) }} %</td>
        </tr>
        <tr>
          <td>五星</td>
          <td>{{ info.osr_info.osr_number.total['5'] }} 抽</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_number.total['5'] / info.osr_info.osr_number.total.all * 100) }} %</td>
        </tr>
        <tr>
          <td>四星</td>
          <td>{{ info.osr_info.osr_number.total['4'] }} 抽</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_number.total['4'] / info.osr_info.osr_number.total.all * 100) }} %</td>
        </tr>
        <tr>
          <td>三星</td>
          <td>{{ info.osr_info.osr_number.total['3'] }} 抽</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_number.total['3'] / info.osr_info.osr_number.total.all * 100) }} %</td>
        </tr>
      </tbody>
    </table>
  </div>

  <h3>平均出货次数</h3>
  <div class="table-responsive">
    <table class="table table-striped table-sm" style="border-collapse: collapse; table-layout: fixed;">
      <thead>
        <tr>
          <th scope="col">干员</th>
          <th scope="col">抽数</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>六星</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_lucky_avg['6']) }} 抽</td>
        </tr>
        <tr>
          <td>五星</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_lucky_avg['5']) }} 抽</td>
        </tr>
        <tr>
          <td>四星</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_lucky_avg['4']) }} 抽</td>
        </tr>
        <tr>
          <td>三星</td>
          <td>{{ "%.2f" | format(info.osr_info.osr_lucky_avg['3']) }} 抽</td>
        </tr>
      </tbody>
    </table>
  </div>

  <h3>各卡池保底情况</h3>
  <div class="table-responsive">
    <table class="table table-striped table-sm" style="border-collapse: collapse; table-layout: fixed;">
      <thead>
        <tr>
          <th scope="col">卡池</th>
          <th scope="col">未出六星抽数</th>
        </tr>
      </thead>
      <tbody>
        {% for key, value in info.osr_info.osr_lucky_count.items() %}
          <tr>
            <td>{{ key }}</td>
            <td>{{ value['6'] }} 抽</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <h3>各卡池抽卡次数</h3>
  <div class="table-responsive">
    <table class="table table-striped table-sm" style="border-collapse: collapse; table-layout: fixed;">
      <thead>
        <tr>
          <th scope="col">卡池</th>
          <th scope="col">抽数</th>
        </tr>
      </thead>
      <tbody>
        {% for key, value in info.osr_info.osr_number.items() %}
          {% if key != 'total' %}
            <tr>
              <td>{{ key }}</td>
              <td>{{ value }} 抽</td>
            </tr>
          {% endif %}
        {% endfor %}
      </tbody>
    </table>
  </div>

  <h3>每月抽卡次数</h3>
  <div class="table-responsive">
    <table class="table table-striped table-sm" style="border-collapse: collapse; table-layout: fixed;">
      <thead>
        <tr>
          <th scope="col">日期</th>
          <th scope="col">抽数</th>
        </tr>
      </thead>
      <tbody>
        {% for key, value in info.osr_info.osr_number_month.items() %}
          {% if key != 'total' %}
            <tr>
              <td>{{ key }}</td>
              <td>{{ value }} 抽</td>
            </tr>
          {% endif %}
        {% endfor %}
      </tbody>
    </table>
  </div>

  <h3>六星历史记录</h3>
  <div class="table-responsive">
    <table class="table table-striped table-sm" style="border-collapse: collapse; table-layout: fixed;">
      <thead>
        <tr>
          <th scope="col">日期</th>
          <th scope="col">卡池</th>
          <th scope="col">抽数</th>
          <th scope="col">干员</th>
          <th scope="col">新增</th>
        </tr>
      </thead>
      <tbody>
        {% for row in info.osr_info.osr_six_record %}
          <tr>
            <td>{{ row.time }}</td>
            <td>{{ row.pool }}</td>
            <td>{{ row.count }} 抽</td>
            <td>{{ row.name }}</td>
            <td>
              {% if row.is_new == true %}
                √
              {% endif %}
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <h2>充值记录</h3>
  <div class="table-responsive">
    <table class="table table-striped table-sm" style="border-collapse: collapse; table-layout: fixed;">
      <thead>
        <tr>
          <th scope="col">日期</th>
          <th scope="col">名称</th>
          <th scope="col">金额</th>
          <th scope="col">平台</th>
        </tr>
      </thead>
      <tbody>
        {% for row in info.pay_info.pay_info %}
          <tr>
            <td>{{ row.time }}</td>
            <td>{{ row.name }}</td>
            <td>￥{{ row.amount }}</td>
            <td>{{ row.platform }}</td>
          </tr>
        {% endfor %}
        <tr>
          <td>合计</td>
          <td></td>
          <td>￥{{ info.pay_info.total_money }}</td>
          <td></td>
        </tr>
      </tbody>
    </table>
  </div>
{% endblock %}